/*
 * application.cpp
 *
 *  Created on: 2010-05-27
 *      Author: mateusz
 */

#include <ClanLib/core.h>
#include <ClanLib/display.h>
#include <ClanLib/gl.h>
#include <ClanLib/application.h>
#include <ClanLib/network.h>

#include "Dyna.h"

class Application
{
public:
	static int main(const std::vector<CL_String> &args);
};

CL_ClanApplication app(&Application::main);

int Application::main(const std::vector<CL_String> &args) {
	CL_SetupCore setup_core;
	CL_SetupDisplay setup_display;
	CL_SetupGL setup_gl;
	CL_SetupNetwork setup_network;

	try
	{
		if( args.size() != 2 ) {
			CL_Console::write("Usage: dyna <ip>\n");
		} else {
			CL_DisplayWindow window("Dyna", 380, 380);
			CL_ConsoleLogger logger;

			CL_ResourceManager resources;
			resources.load("resources/resources.xml");

			Client client;
			client.connect(args[1]);

			Dyna dyna(&window, &resources, &client);
			CL_Slot slot_quit = window.sig_window_close().connect(&dyna, &Dyna::slotQuit);
			dyna.exec();
		}

	} catch (CL_Exception e) {
		CL_Console::write_line(e.message);
	}

	return 0;
}
